package com.zt.controller;

import com.zt.pojo.Result;
import com.zt.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/upload")
public class UploadController {
    @Autowired
    private UploadService uploadService;
    @PostMapping
    public Result upload(MultipartFile file){
        String url = null;
        try {
            url = uploadService.upload(file);
        } catch (Exception e) {
            Result.error("上传失败");
        }
        return Result.success(url);
    }
}
